// Copyright 2011 Jefferson Willian
// willmont7@gmail.com

#include <cstdio>

#define MAX 1000

int main() {
  int n;
  int higher;
  int stdents[MAX][2];
  int games = 1;

  while (scanf("%d", &n) && n != 0) {
    higher = 0;
    for (int i = 0;i < n;i++) {
      scanf("%d%d", &stdents[i][0], &stdents[i][1]);
      if (stdents[i][1] > higher)
          higher = stdents[i][1];
    }
    printf("Turma %d\n", games++);

    for (int i = 0;i < n;i++)
      if (stdents[i][1] == higher)
        printf("%d ", stdents[i][0]);
      printf("\n\n");
  }

  return 0;
}
